package com.share.tool.devops.config;

import com.offbytwo.jenkins.JenkinsServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.net.URI;

@Configuration
public class JeninsConfig {
    @Autowired
    private JeninsProperties jeninsProperties;

    @Bean
    public JenkinsServer jenkinsServer() {
        try {
            return new JenkinsServer(new URI(jeninsProperties.getUrl(), jeninsProperties.getUsername(), jeninsProperties.getPassword()));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
